<template>
    <div>
        <a-form style="max-width: 500px; margin: 40px auto 0;">
            <a-form-item
                    label="后台生成模式"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 17}"
            >
                <a-select v-model="project.projectJavaPattern">
                    <a-select-option key="true">
                        整体项目
                    </a-select-option>
                    <a-select-option key="false">
                        代码加目录结构模式
                    </a-select-option>
                </a-select>
            </a-form-item>
            <a-form-item
                    label="前台生成模式"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 17}"
            >
                <a-select v-model="project.projectVuePattern">
                    <a-select-option  key="true">
                        整体项目
                    </a-select-option>
                    <a-select-option key="false">
                        代码加目录结构模式
                    </a-select-option>
                </a-select>
            </a-form-item>
            <a-form-item
                    label="生成路径"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 17}"
                    :validate-status="validate.path.pass? '':'error'"
                    :help="validate.path.pass? '':validate.path.help"
            >
                <a-input v-model="project.path" />
            </a-form-item>
            <a-form-item :wrapperCol="{span: 17, offset: 7}">
                <a-button style="margin-left: 8px;margin-right: 50px" @click="prevStep">上一步</a-button>
                <a-button type="primary" @click="nextStep">开始生成</a-button>
            </a-form-item>
        </a-form>
    </div>
</template>

<script>
    export default {
        name: 'Step5',
        data () {
            return {
                validate:{
                    path: {
                        pass: true,
                    }
                }
            }
        },
        props:{
            project: Object,
        },
        methods: {
            verify() {
                let flag = true;
                if (this.project.path == undefined || this.project.path == '') {
                    this.validate.path.pass = false;
                    this.validate.path.help = '生成路径不为空';
                    flag = false;
                } else {
                    this.validate.path.pass = true;
                }
                return flag;
            },
            nextStep () {
                if (!this.verify()) {
                    return;
                }
                this.$emit('changeProject',this.project);
                this.$emit('submit');
                this.$emit('nextStep');
            },
            prevStep() {
                this.$emit('prevStep');
            }
        }
    }
</script>

<style scoped>

</style>
